home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SIZERC.cpp
-
- Contains: xxx put contents here xxx
-
- Owned by: Nick Pilch
-
- Copyright: © 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 6/21/96 NP first checked in
-
- To Do:
- */
-
- #ifndef SIZERC_H
- #include "SIZERC.h"
- #endif
-
- #ifndef ST_MACCLASSES_H
- #include "ST_MacClasses.h"
- #endif
-
- SIZEResourceHandle GetSIZEResource (short resFile, short id)
- {
- ST_ResFileSaver saver = CurResFile ();
- UseResFile (resFile);
-
- SIZEResourceHandle handle = (SIZEResourceHandle) Get1Resource ('SIZE', id);
- return handle;
- }
-
- OSErr GetOriginalSize (short resFile, Size& minimum, Size& maximum)
- {
- SIZEResourceHandle s = GetSIZEResource (resFile, kOriginalSIZEResourceID);
- if (s) {
- minimum = (**s).minimumMemorySize;
- maximum = (**s).preferredMemorySize;
- ReleaseResource ((Handle)s);
- return noErr;
- } else {
- minimum = maximum = 0;
- return resNotFound;
- }
- }
-
- OSErr GetCustomSize (short resFile, Size& minimum, Size& maximum)
- {
- SIZEResourceHandle s;
-
- s = GetSIZEResource (resFile, kMaximumSIZEResourceID);
- if (s) {
- maximum = (**s).preferredMemorySize;
- ReleaseResource ((Handle)s);
- } else {
- minimum = maximum = 0;
- return resNotFound;
- }
-
- s = GetSIZEResource (resFile, kMinimumSIZEResourceID);
- if (s) {
- minimum = (**s).minimumMemorySize;
- ReleaseResource ((Handle)s);
- } else {
- minimum = maximum = 0;
- return resNotFound;
- }
-
- return noErr;
- }
-
- OSErr SetCustomSize (short resFile, Size minimum, Size maximum)
- {
- OSErr error;
- ST_ResourceHandle original = (Handle) GetSIZEResource (resFile, kOriginalSIZEResourceID);
- if (!(Handle) original)
- return resNotFound;
-
- /* set the minimum size, creating a resource if necessary */
-
- SIZEResourceHandle minCustom = GetSIZEResource (resFile, kMinimumSIZEResourceID);
- if (!minCustom) {
- minCustom = (SIZEResourceHandle)(Handle) original;
- error = HandToHand ((Handle*) &minCustom);
- if (error)
- return resNotFound;
- else {
- AddResource ((Handle) minCustom, 'SIZE', kMinimumSIZEResourceID, "\p");
- error = ResError ();
- if (error)
- return error;
- }
- }
-
- (**minCustom).minimumMemorySize = minimum;
- ST_ResourceHandle minimumHandle ((Handle) minCustom);
-
- /* set the maximum size, creating a resource if necessary */
-
- SIZEResourceHandle maxCustom = GetSIZEResource (resFile, kMaximumSIZEResourceID);
- if (!maxCustom) {
- maxCustom = (SIZEResourceHandle)(Handle) original;
- error = HandToHand ((Handle*) &maxCustom);
- if (error)
- return resNotFound;
- else {
- AddResource ((Handle) maxCustom, 'SIZE', kMaximumSIZEResourceID, "\p");
- error = ResError ();
- if (error)
- return error;
- }
- }
-
- (**maxCustom).preferredMemorySize = maximum;
- ST_ResourceHandle maximumHandle ((Handle) maxCustom);
-
- WriteResource ((Handle) minimumHandle);
- WriteResource ((Handle) maximumHandle);
-
- return noErr;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-